const {
    createProxyMiddleware
} = require("http-proxy-middleware")
const services = require("./services");
 
module.exports = function (app) {
    for (const key in services.mapService) {
        const val = services.mapService[key]
        app.use(
            createProxyMiddleware(key, { //`api`是需要转发的请求
                BASE_URL: key,
                target: val.target,
                changeOrigin: true,
                pathRewrite: {
                    [`^${key}`]: val.pathRewrite,
                }
            })
        )
    }
}
